package com.example.page

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.ui.Modifier
import androidx.paging.compose.collectAsLazyPagingItems
import com.example.page.ui.quotes.QuotesScreen
import com.example.page.ui.quotes.viewModel.QuotesViewModel
import com.example.page.ui.theme.PageTheme

class MainActivity : ComponentActivity() {
    private val quotesViewModel: QuotesViewModel by viewModels()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            PageTheme {
                val quotesPagingItems = quotesViewModel.quotes.collectAsLazyPagingItems()
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colorScheme.background
                ) {
                    QuotesScreen(quotes = quotesPagingItems)
                }
            }
        }
    }
}